package blocos;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;

import blocos.BlockBit;

@SuppressWarnings("serial")
public class BlockBitGUI extends BlockGUI{
	int fontSize = 64;
	private Font font;
	private Font fontBig = new Font("Monospaced",Font.BOLD,64);
	private Font fontMedium = new Font("Monospaced",Font.BOLD,48);
	private Font fontSmall = new Font("Monospaced",Font.BOLD,32);
	
	public BlockBitGUI(String s){
		block = new BlockBit(s);
	}

	public void paintComponent(Graphics g){
		super.paintComponent(g);
		if(scale == 1) font = fontBig;
		else if (scale == 0.75) font = fontMedium;
		else font = fontSmall;
		g.setFont(font);
		g.setColor(Color.black);
        g.drawString(((BlockBit)block).value,x+width/2-font.getSize()/4,y+height/2+font.getSize()/4);

//        if(this.block.right!=null)
//	    {
//	    	g.setColor(Color.BLACK);
//	    	g.fillRect(x + (int)(width*0.95), y + (int)(height*0.475), (int)(width*0.05), (int)(height*0.05));
//	    }
//	    if(this.block.left!=null)
//	    {
//	    	g.setColor(Color.BLACK);
//	    	g.fillRect(x + (int)(width*0.05), y + (int)(height*0.475), (int)(width*0.05), (int)(height*0.05));
//	    }
//	    if(this.block.top!=null)
//	    {
//	    	g.setColor(Color.BLACK);
//	    	g.fillRect(x + (int)(width*0.125), y + (int)(height*0.05), (int)(width*0.05), (int)(height*0.05));
//	    }
//	    if(this.block.bottom!=null)
//	    {
//	    	g.setColor(Color.BLACK);
//	    	g.fillRect(x + (int)(width*0.125), y + (int)(height*0.95), (int)(width*0.05), (int)(height*0.05));
//	    }
        

	}
	
	//persistencia

	public BlockBitGUI(String[]parametros){
			
			int x = Integer.parseInt(parametros[0]);
			int y = Integer.parseInt(parametros[1]);
			this.x = x;
			this.y = y ;
			block = new BlockBit(parametros[2]);
		}
	
	
	public String[] save() {
		String[] p = new String [5];
		p[0]="BlockBitGUI";
		p[1]=Integer.toString(this.x);
		p[2]=Integer.toString(this.y);
		p[3]=this.block.save()[0];
		return p;
	}
}
